<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>测试登录</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#btn").click(function () {
                $.post(
                    $("form").prop("action"),
                    //{username:$("[name='username']").val(),password:$("[name='password']").val()},
                    $("form").serialize(),
                    function (obj) {
                        if(obj){
                            alert("登录成功");
                        }else{
                            alert("登录失败");
                        }
                    },
                    "json"
                );
            });
        });
    </script>
</head>
<body>

<form action="${pageContext.request.contextPath}/testLogin" method="post">
    用户名：<input type="text" name="username"><br>
    密码：<input type="password" name="password"><br>
    <input type="button" value="登录" id="btn"><br>
</form>

</body>
</html>
